package com.tangyh.basic.sign.factory.filetemplate;

import com.alibaba.fastjson.annotation.JSONField;
import com.tangyh.basic.sign.enums.RequestType;
import com.tangyh.basic.sign.factory.request.Request;
import com.tangyh.basic.sign.factory.response.CreateTemplateComponentsResponse;
import java.util.List;

/**
 * @Author: LiXincheng
 * @Description:
 * @Date: 2021/12/7 15:15
 */
public class CreateTemplateComponents extends Request<CreateTemplateComponentsResponse> {

    private List<StructComponentDTO> structComponent;

    @JSONField(serialize = false)
    private String templateId;

    //禁止构造无参对象
    private CreateTemplateComponents() {}

    public CreateTemplateComponents(
        List<StructComponentDTO> structComponent,String templateId) {
        this.structComponent = structComponent;
        this.templateId=templateId;
    }

    @Override
    public void build() {
        super.setUrl("/v1/docTemplates/"+templateId+"/components");
        super.setRequestType(RequestType.POST);
    }

    public static class StructComponentDTO {

        private String id;
        private String key;
        private Integer type;
        private ContextDTO context;

        public static class ContextDTO {

            private String label;
            private String limit;
            private Boolean required;
            private StyleDTO style;
            private PosDTO pos;

            public static class StyleDTO {

                private Integer font;
                private Integer fontSize;
                private String textColor;
                private Double width;
                private Double height;

                public Integer getFont() {
                    return font;
                }

                public void setFont(Integer font) {
                    this.font = font;
                }

                public Integer getFontSize() {
                    return fontSize;
                }

                public void setFontSize(Integer fontSize) {
                    this.fontSize = fontSize;
                }

                public String getTextColor() {
                    return textColor;
                }

                public void setTextColor(String textColor) {
                    this.textColor = textColor;
                }

                public Double getWidth() {
                    return width;
                }

                public void setWidth(Double width) {
                    this.width = width;
                }

                public Double getHeight() {
                    return height;
                }

                public void setHeight(Double height) {
                    this.height = height;
                }
            }

            public static class PosDTO {

                private Double x;
                private Double y;
                private Integer page;

                public Double getX() {
                    return x;
                }

                public void setX(Double x) {
                    this.x = x;
                }

                public Double getY() {
                    return y;
                }

                public void setY(Double y) {
                    this.y = y;
                }

                public Integer getPage() {
                    return page;
                }

                public void setPage(Integer page) {
                    this.page = page;
                }
            }

            public String getLabel() {
                return label;
            }

            public void setLabel(String label) {
                this.label = label;
            }

            public String getLimit() {
                return limit;
            }

            public void setLimit(String limit) {
                this.limit = limit;
            }

            public Boolean getRequired() {
                return required;
            }

            public void setRequired(Boolean required) {
                this.required = required;
            }

            public StyleDTO getStyle() {
                return style;
            }

            public void setStyle(
                StyleDTO style) {
                this.style = style;
            }

            public PosDTO getPos() {
                return pos;
            }

            public void setPos(
                PosDTO pos) {
                this.pos = pos;
            }
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }

        public Integer getType() {
            return type;
        }

        public void setType(Integer type) {
            this.type = type;
        }

        public ContextDTO getContext() {
            return context;
        }

        public void setContext(
            ContextDTO context) {
            this.context = context;
        }
    }

    public List<StructComponentDTO> getStructComponent() {
        return structComponent;
    }

    public void setStructComponent(
        List<StructComponentDTO> structComponent) {
        this.structComponent = structComponent;
    }

    public String getTemplateId() {
        return templateId;
    }

    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }
}
